package main

import (
	"context"
	"fmt"
	"time"
)

var TimeTickMap1 = make(map[int32]chan struct{})

func main() {
	//go test()
	//go test2()
	var i = 0
	for {
		i++
		ctx := context.Background()
		//ctx, cancel := context.WithCancel(ctx)
		go test3(ctx)
		fmt.Println(i)
		//time.Sleep(time.Millisecond * 50)
		//cancel()
	}
}

func test3(ctx context.Context) {
	for {
		select {
		case <-ctx.Done():
			return
		}
	}
}

func test() {
	TimeTickMap1[1] = make(chan struct{})
	defer delete(TimeTickMap1, 1)
	for {
		time.Sleep(time.Second * 3)
		_, ok := TimeTickMap1[1]
		fmt.Println(ok)
	}
}

func test2() {
	for {
		time.Sleep(time.Second * 1)
		_, ok := TimeTickMap1[1]
		fmt.Println(ok)
	}
}
